package cn.edu.zut.score.controller.admin;

import cn.edu.zut.score.core.domain.PageResponse;
import cn.edu.zut.score.core.domain.RestResponse;
import cn.edu.zut.score.core.dto.request.ConfigPageRequest;
import cn.edu.zut.score.core.dto.response.ConfigResponse;
import cn.edu.zut.score.core.entity.Config;
import cn.edu.zut.score.service.IConfigService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zby
 * @date 2021/06/27
 */
@RestController
@RequestMapping("/admin/config")
@CrossOrigin
public class AdminConfigController {

    @Autowired
    private IConfigService iConfigService;

    @ApiOperation("获取配置列表")
    @PostMapping("")
    public RestResponse<PageResponse<ConfigResponse>> getAllConfigs(@RequestBody ConfigPageRequest configPageRequest) {
        return iConfigService.getAllConfigs(configPageRequest);
    }

    @ApiOperation("修改配置信息")
    @PutMapping("")
    public RestResponse<ConfigResponse> updateConfig(@RequestBody Config config) {
        return iConfigService.updateConfig(config);
    }

}
